#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>


uint8_t buffer[512] = {0};

int main(int argc, char *argv[])
{
    int fd;
    int ret;
    
    fd = open(argv[1], O_RDWR);
    
    if(!strcmp("read", argv[2]))
    {
        printf("read data from kernel \r\n");
        ret = read(fd, buffer, sizeof(buffer));
        printf("ret len:%d data:%s\r\n",ret,buffer);
    }

    if(!strcmp("write", argv[2]))
    {
        printf("write data from kernel %s len:%d \r\n",argv[3],strlen(argv[3]));
        ret = write(fd, argv[3], strlen(argv[3]));
        printf("ret len:%d\r\n",ret);
    }


    close(fd);

}
